package com.talent.web.controller;

import com.talent.web.model.TalentResult;
import com.talent.web.pay.AlipayService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName：AlipayController
 * @Author: hszhou
 * @Date: 2025/3/24 14:18
 * @Description: 支付宝相关接口
 */
@RestController
@RequestMapping("alipay")
@RequiredArgsConstructor
@Slf4j
public class AlipayController {

    private final AlipayService alipayService;

    @PostMapping("pay/{orderId}")
    public TalentResult<String> pay(@PathVariable("orderId") Long orderId){
        String body = alipayService.appPay(orderId);
        return TalentResult.success(body);
    }
    /**
     * 异步回调通知接口
     * @param request 请求
     */
    @PostMapping("callback")
    public void callback(HttpServletRequest request){

        log.info("收到支付宝回调");
        alipayService.callback(request);
    }


}
